﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;
using T.FAS.Runtime.Base.SGSPI;

namespace T.FAS.Runtime.Base.Service
{
    public class IconLibraryService: IIconLibraryService
    {
        readonly IconLibraryELBDao dao;
        public IconLibraryService() {
            dao = new IconLibraryELBDao();
        }
        public List<IconLibrary> QueryIconLibrarys(string filter) {
            Dictionary<string, string> filterDic = new Dictionary<string, string>();
            if (!string.IsNullOrEmpty(filter)) {
                filterDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(filter);
            }
            return dao.GetIconLibrarys(filterDic);
        }

        public void AddIconLibrary(IconLibrary iconLibrary) {
            if(string.IsNullOrEmpty(iconLibrary.ID)){
                iconLibrary.ID = Guid.NewGuid().ToString();
            }
            iconLibrary.Creator = "T";
            iconLibrary.CreateTime = DateTime.Now;
            iconLibrary.LastModifier = iconLibrary.Creator;
            iconLibrary.LastModifyTime = iconLibrary.CreateTime;
            dao.Add(new List<object>() { iconLibrary});
        }
        public void DeleteIconLibrary(string id)
        {            
            dao.Delete(new List<string>() { id });
        }
    }
}
